<?php
$link = mysql_connect("localhost", "root", "1234");
mysql_select_db("busticket", $link);
$query = "create database busticket";
mysql_query($query,$link);
$query = "create table member
(
id int auto_increment,
primary key(id),
name varchar(50),
lastname varchar(50),
username varchar(50),
password varchar(50),
idcard varchar(50),
email varchar(50)
);";
mysql_query($query,$link);
$query = "create table logticket
(
id int auto_increment,
primary key(id),
memberid int,
busid int,
price double,
detail varchar(255),
foreign key(memberid) references member(id),
foreign key(busid) references listbus(id)
);";
mysql_query($query,$link);
$query = "create table listbus
(
id int auto_increment,
primary key(id),
route varchar(255),
xtime varchar(50),
ytime varchar(50),
bustype varchar(50),
price double
);";
mysql_query($query,$link);
$query = "create table busseat
(
id int auto_increment,
primary key(id),
seatname varchar(50),
busid int,
foreign key(busid) references listbus(id)
);";
mysql_query($query,$link);
mysql_close($link);
?>